package com.xiaomi.controller;

import com.alibaba.fastjson.JSON;
import com.xiaomi.entity.OrderKauizhao;
import com.xiaomi.model.Result;
import com.xiaomi.service.OrderKuaiZhaoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @ClassName OrderKuaiZhaoController
 * @Description TODO
 * @Author WL
 * @Date 2021/12/1 21:46
 * @Version 1.0
 **/
@Controller
@RequestMapping(value = "/kuaizhao", produces = "application/json;charset=utf-8")
public class OrderKuaiZhaoController {
    @Autowired
    private OrderKuaiZhaoService orderKuaiZhaoService;
    @GetMapping("/list.do")
    @ResponseBody
    public String listSearch(@RequestParam Integer page,
                             @RequestParam Integer limit,
                             @RequestParam(required = false) Integer orderId){
        Integer startRow = (page - 1) * limit;
        List<OrderKauizhao> lists = orderKuaiZhaoService.listSearch(startRow,limit,orderId);
        Integer count = orderKuaiZhaoService.getCount();
        Result result = new Result();
        result.setCode(0);
        result.setCount(count);
        result.setData(lists);
        result.setMsg("成功");
        String json = JSON.toJSONString(result);
        return json;

    }
}
